home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / PRGMMING / CPP100.ZIP / CPPLMEN7.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-22  |  10.2 KB  |  359 lines

  1. /*****************************************************************************/
  2. /*       (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved         */
  3. /*****************************************************************************/
  4. /*    This source-code is NOT public domain nor Freeware, this is part of    */
  5. /*              'The C Programming Package' which is Shareware.              */
  6. /*   If you use this code, please register and get a free Full-VGA version   */
  7. /*****************************************************************************/
  8.                                 /*----------------*
  9.                                  *   CPPLMEN7.C   *
  10.                                  * Menu manager7  *
  11.                                  *----------------*/
  12.  
  13.  /* Included Files */
  14.  # include <stdio.h>
  15.  # include <io.h>
  16.  # include <dos.h>
  17.  # include <fcntl.h>
  18.  # include <bios.h>
  19.  # include <stdlib.h>
  20.  # include <conio.h>
  21.  
  22.  /* Global Variables */
  23.  extern int bm,i,j,k,l,m,n,t,x,x1,x2,xm,y,y1,y2,ym,z,menu0,menu7,return1;
  24.  extern int colour1,colour2,colour3,colour4,colour5,returning;
  25.  extern unsigned char c0,c1,trashcan[];
  26.  
  27.  /*----------------------*
  28.   * CHOICE DISPLAY HELP7 *
  29.   *----------------------*/
  30.   void choice_display_help7()
  31.     {
  32.       /* We display the help that concerns the line on */
  33.       /* which is the menu cursor (in red).            */
  34.       if(menu7==1){
  35.     /*  */
  36.         display_help("MENU7   ",65,2,1);     restore_help_screen();
  37.       }
  38.       if(menu7==2){
  39.     /*  */
  40.         display_help("MENU7   ",66,3,1);     restore_help_screen();
  41.       }
  42.       if(menu7==3){
  43.     /*  */
  44.         display_help("MENU7   ",67,4,1);     restore_help_screen();
  45.       }
  46.       if(menu7==4){
  47.     /*  */
  48.         display_help("MENU7   ",68,5,1);     restore_help_screen();
  49.       }
  50.       if(menu7==5){
  51.     /*  */
  52.         display_help("MENU7   ",69,6,1);     restore_help_screen();
  53.       }
  54.       if(menu7==6){
  55.     /*  */
  56.         display_help("MENU7   ",70,7,1);     restore_help_screen();
  57.       }
  58.       if(menu7==7){
  59.         /* available */
  60.         display_help("MENU7   ",71,8,1);     restore_help_screen();
  61.       }
  62.       if(menu7==8){
  63.     /*  */
  64.         display_help("MENU7   ",72,9,1);     restore_help_screen();
  65.       }
  66.       if(menu7==9){
  67.     /*  */
  68.         display_help("MENU7   ",73,10,1);    restore_help_screen();
  69.       }
  70.       if(menu7==10){
  71.     /*  */
  72.         display_help("MENU7   ",74,11,1);    restore_help_screen();
  73.       }
  74.     }
  75.  /*----------------*
  76.   * GET THE MOUSE7 *
  77.   *----------------*/
  78.   int get_the_mouse7()
  79.     {
  80.       /* If we choose with the mouse */
  81.       /* Only  available for menu 1  */
  82.       if(ym==1){
  83.         /* We clicked on the first line, certainly */
  84.         /* To change of menu.                      */
  85.         x=get_the_mouse0();
  86.     menu0=x;                       return(-2);
  87.       }
  88.       if((xm>46)&&(xm<63)){
  89.     if(ym==3){
  90.       /*  */
  91.       menu7=1;                   return(1);
  92.     }
  93.     if(ym==4){
  94.       /*  */
  95.       menu7=2;                     return(1);
  96.     }
  97.     if(ym==5){
  98.       /*  */
  99.       menu7=3;                     return(1);
  100.     }
  101.     if(ym==6){
  102.       /*  */
  103.       menu7=4;                     return(1);
  104.     }
  105.     if(ym==7){
  106.       /*  */
  107.       menu7=5;                     return(1);
  108.     }
  109.     if(ym==8){
  110.       /*  */
  111.       menu7=6;                     return(1);
  112.     }
  113.     if(ym==9){
  114.       /*  */
  115.       menu7=7;                     return(1);
  116.     }
  117.     if(ym==10){
  118.       /*  */
  119.       menu7=8;                     return(1);
  120.     }
  121.     if(ym==11){
  122.       /*  */
  123.       menu7=9;                     return(1);
  124.     }
  125.     if(ym==12){
  126.       /*  */
  127.       menu7=10;                    return(1);
  128.     }
  129.       }
  130.       /* If we clicked outside the menu zone            */
  131.       /* we want to erase the menu and return to menu 0 */
  132.       /*  */
  133.       menu0=0;                         return(-2);
  134.     }
  135.  /*--------------*
  136.   * MENU CHOICE7 *
  137.   *--------------*/
  138.   int menu_choice7()
  139.     {
  140.       returning=wait_for_a_key();
  141.       /* Else we pressed a keyboard key                            */
  142.       /* Cf CPPLTC2.C for the keyboard test and the returned codes */
  143.       if(returning==-1){
  144.         /* <Esc> we want to go back to menu0 */
  145.     menu0=0;                       return(-2);
  146.       }
  147.       if(returning==40){
  148.         /* <Enter> execute the command */
  149.     return(1);
  150.       }
  151.       if(returning==100){
  152.         /* We pressed a mouse button */
  153.         m=get_the_mouse7();  return(m);
  154.       }
  155.       /* The key letters depends on the menu  */
  156.  
  157.       /* So the below returns need to be modified */
  158.       if(returning==24){
  159.     /* <O> <o>  */
  160.     menu7=1;                       return(1);
  161.       }
  162.       if(returning==23){
  163.     /* <N> <n>  */
  164.     menu7=2;                       return(1);
  165.       }
  166.       if(returning==28){
  167.     /* <S> <s>  */
  168.     menu7=3;                       return(1);
  169.       }
  170.       if(returning==13){
  171.     /* <D> <d>  */
  172.     menu7=5;                       return(1);
  173.       }
  174.       if(returning==27){
  175.     /* <R> <r>  */
  176.     menu7=6;                       return(1);
  177.       }
  178.       if(returning==18){
  179.     /* <I> <i>  */
  180.     menu7=7;                       return(1);
  181.       }
  182.       if(returning==15){
  183.     /* <F> <f>  */
  184.     menu7=8;                       return(1);
  185.       }
  186.       if(returning==26){
  187.     /* <Q> <q>  */
  188.     menu7=10;                   return(1);
  189.       }
  190.       /* For the 2-bytes coded keys, this is the second byte */
  191.       if(returning==59){
  192.          /* Function key <F1> = help */
  193.      return(59);
  194.       }
  195.       if(returning>100){
  196.         /* We pressed Alt + another key to get a menu */
  197.         c1=returning-100;                 k=get_special_menu00();
  198.     if(k>0)                        return(-2);
  199.       }
  200.       if((returning==77)||(returning==75)){
  201.         /* Left or Right arrow to change of menu */
  202.         c1=returning;                             k=get_special_menu00();
  203.     if(k>0)                        return(-2);
  204.       }
  205.       if(returning==72){
  206.         /* Up arrow */
  207.     if(menu7>1)                    menu7--;
  208.     else                           menu7=10;
  209.     return(0);
  210.       }
  211.       if(returning==80){
  212.         /* Down arrow */
  213.     if(menu7<10)                   menu7++;
  214.     else                           menu7=1;
  215.     return(0);
  216.       }
  217.       /* Else we return 0 = no choice */
  218.       return(0);
  219.     }
  220.  /*--------------------*
  221.   * DISPLAY LINE menu7 *
  222.   *--------------------*/
  223.   void display_menu_line7()
  224.     {
  225.       /* First we display the chosen menu0 */
  226.       textattr(colour5);
  227.       gotoxy(49,1);                    cputs("  Menu7  ");
  228.       /* Same thing for the selected line */
  229.       if(menu7==1){
  230.     gotoxy(47,3);                  cputs("                ");
  231.       }
  232.       if(menu7==2){
  233.     gotoxy(47,4);                  cputs("                ");
  234.       }
  235.       if(menu7==3){
  236.     gotoxy(47,5);                  cputs("                ");
  237.       }
  238.       if(menu7==4){
  239.     gotoxy(47,6);                  cputs("                ");
  240.       }
  241.       if(menu7==5){
  242.     gotoxy(47,7);                  cputs("                ");
  243.       }
  244.       if(menu7==6){
  245.     gotoxy(47,8);                  cputs("                ");
  246.       }
  247.       if(menu7==7){
  248.     gotoxy(47,9);                  cputs("                ");
  249.       }
  250.       if(menu7==8){
  251.     gotoxy(47,10);                 cputs("                ");
  252.       }
  253.       if(menu7==9){
  254.     gotoxy(47,11);                 cputs("                ");
  255.       }
  256.       if(menu7==10){
  257.     gotoxy(47,12);                 cputs("                ");
  258.       }
  259.     }
  260.  /*----------------------*
  261.   * DISPLAY KEY LETTER 7 *
  262.   *----------------------*/
  263.   void display_key_letter7()
  264.     {
  265.       textattr(116);
  266.       gotoxy(48,3);                   cputs(" ");
  267.       gotoxy(48,4);                   cputs(" ");
  268.       gotoxy(48,5);                   cputs(" ");
  269.       gotoxy(48,6);                   cputs(" ");
  270.       gotoxy(48,7);                   cputs(" ");
  271.       gotoxy(48,8);                   cputs(" ");
  272.       gotoxy(48,9);                   cputs(" ");
  273.       gotoxy(48,10);                  cputs(" ");
  274.       gotoxy(48,11);                  cputs(" ");
  275.       gotoxy(48,12);                  cputs(" ");
  276.     }
  277.  /*---------------*
  278.   * DISPLAY menu7 *
  279.   *---------------*/
  280.   void display_menu7()
  281.     {
  282.       /* To avoid the trace of the previous mouse position */
  283.       /* we hide it during the display,                    */
  284.       /* and show it when the line has been displayed.     */
  285.       hide_the_mouse();               textattr(colour2);
  286.       gotoxy(45,2);                    cputs(" ┌────────────────┐ ");
  287.       gotoxy(45,3);                    cputs(" │                │ ");
  288.       gotoxy(45,4);                    cputs(" │                │ ");
  289.       gotoxy(45,5);                    cputs(" │                │ ");
  290.       gotoxy(45,6);                    cputs(" │                │ ");
  291.       gotoxy(45,7);                    cputs(" │                │ ");
  292.       gotoxy(45,8);                    cputs(" │                │ ");
  293.       gotoxy(45,9);                    cputs(" │                │ ");
  294.       gotoxy(45,10);                   cputs(" │                │ ");
  295.       gotoxy(45,11);                   cputs(" │                │ ");
  296.       gotoxy(45,12);                   cputs(" │                │ ");
  297.       gotoxy(45,13);                   cputs(" └────────────────┘ ");
  298.       display_key_letter7();           display_menu_line7();
  299.       show_the_mouse();
  300.     }
  301.  /*----------------*
  302.   * MENU MANAGER 7 *
  303.   *----------------*/
  304.   int menu_manager7()
  305.     {
  306.       restore_screen();                return1=0;
  307.       while(1){
  308.         display_menu7();               return1=menu_choice7();
  309.         if(return1==-2)                return(-2);
  310.         if(return1==-1)                return(-1);
  311.         if(return1==22)                choice_display_help7();
  312.         display_menu7();
  313.         if(return1==1){
  314.           /* We execute the selected function */
  315.       if(menu7==10){
  316.             /* We want to quit the sub-program */
  317.         return(-1);
  318.       }
  319.       if(menu7==1){
  320.         /*  */
  321.  
  322.       }
  323.       if(menu7==2){
  324.         /*  */
  325.  
  326.       }
  327.       if(menu7==3){
  328.         /*  */
  329.  
  330.       }
  331.       if(menu7==4){
  332.         /*  */
  333.  
  334.       }
  335.       if(menu7==5){
  336.         /*  */
  337.  
  338.       }
  339.       if(menu7==6){
  340.         /*  */
  341.  
  342.       }
  343.       if(menu7==7){
  344.         /*  */
  345.  
  346.       }
  347.       if(menu7==8){
  348.         /*  */
  349.  
  350.       }
  351.       if(menu7==9){
  352.         /*  */
  353.  
  354.       }
  355.     }
  356.       }
  357.     }
  358. /* End of the Module *//*----------------*/
  359.